﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _21.Exercise
{
    class Program
    {
        static void Main(string[] args)
        {
            string text1="Write a program that reads a string from the console and prints all different letters in the string along with information how many times each letter is found.";
            string text = text1.ToLower();
            Dictionary<char, int> dict = new Dictionary<char, int>();
            foreach (char item in text)
            {
                if (Char.IsLetter(item))
                {
                    if (!dict.ContainsKey(item))
                    {
                        dict.Add(item, 1);
                    }
                    else
                    {
                        dict[item] = dict[item] + 1;
                    }
                }
            }
            var sortedLetters = dict.OrderBy(x => x.Key);
            foreach (KeyValuePair<char,int> item in sortedLetters)
            {                
                Console.WriteLine(item);
            }
        }
    }
}
